﻿ 
using System.Web.Mvc;
using CarTrackr.Business;
using CarTrackr.Business.Services;
using CarTrackr.Controllers;
using CarTrackr.Tests.Repository;
using Microsoft.VisualStudio.TestTools.UnitTesting;
 


namespace CarTrackr.Tests.Controllers
{
    
    [TestClass]
    public class CarControllerTest
    {


        [TestMethod]
        public void TestRemove()
        {

            FakeRepository fakeRepository = new FakeRepository();

            AppService appService = new AppService(fakeRepository);

            User currentUser = fakeRepository.GetCurrentUser();

            CarController carController = new CarController(appService, currentUser);

            carController.Remove("ENN781");

            Assert.AreEqual(1, currentUser.Cars.Count);

        }


        [TestMethod]
        public void TestNew()
        {

            FakeRepository fakeRepository = new FakeRepository();

            AppService appService = new AppService(fakeRepository);

            User currentUser = fakeRepository.GetCurrentUser();

            int carsOwned = currentUser.Cars.Count; 
  ; 
            CarController carController = new CarController(appService,currentUser);


            FormCollection formCollection = new FormCollection();

            formCollection.Add("Make", "Toyota");
            formCollection.Add("Model", "Acura");
            formCollection.Add("LicensePlate", "THU121");
            formCollection.Add("PurchasePrice", "31000");
            formCollection.Add("FuelType", "Gas");
            formCollection.Add("Description", "");


            carController.New(formCollection);

            Assert.AreEqual(carsOwned + 1, currentUser.Cars.Count);

    
        }

    }
}

